<template>
  <div class="setting">
    <!-- 顶部 -->
    <van-nav-bar title="设置" left-arrow @click-left="onClickLeft" />
    <!-- 中间内容 -->
    <van-cell title="个人资料" is-link to="/personInfo" />
    <!-- 按钮 -->
    <div class="exit-btn">
      <van-button type="info" block @click="exit">退出当前帐号</van-button>
    </div>
  </div>
</template>

<script>
import { Dialog } from 'vant';
import { mapMutations } from "vuex";

export default {
  data() {
    return {
      visible: true,
    };
  },
  methods: {
    ...mapMutations(["setAddressInfoNow"]),
    //顶部左槽返回上一级
    onClickLeft() {
      this.$router.back(-1);
    },
    exit() {
      Dialog.confirm({
        title: "退出当前帐号",
        message: "确定退出当前帐号?",
      })
        .then(() => {
          // on confirm       
          let clearAddress = {title:"暂时无法获取定位"};
          this.setAddressInfoNow(clearAddress);
          this.$router.push('/login')
          sessionStorage.clear();
        })
        .catch(() => {
          // on cancel
        });
    },
  },
};
</script>

<style lang="scss" scoped>
.setting {
  .exit-btn {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
  }
}
</style>